<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/9
 * Time: 16:55
 */
namespace app\admin\controller;
use app\admin\model\AuthRule;
use think\Controller;

class Base extends Controller{
    private $_tbconfig = null;
    public function _initialize()
    {
        parent::_initialize();
     if(!$this->check_admin_login()) $this->redirect('admin/Login/index');//未登录


        $auth=new AuthRule();
        $id_curr=$auth->get_url_id();//获取当前url在auth_rule表的id
        if(!$auth->check_auth($id_curr)) $this->error('没有权限','admin/index/index');
        //获取有权限的菜单tree
        $menus=$auth->get_admin_menus();
        $this->assign('menus',$menus);
        //当前方法倒推到顶级菜单ids数组
        $menus_curr=$auth->get_admin_parents($id_curr);
        $this->assign('menus_curr',$menus_curr);
        //取当前操作菜单父节点下菜单 当前菜单id(仅显示状态)
//        $menus_child=$auth->get_admin_parent_menus($id_curr);
//        $this->assign('menus_child',$menus_child);
//        $this->assign('id_curr',$id_curr);
//        $this->assign('admin_avatar',session('admin_auth.admin_avatar'));
    }
    protected function check_admin_login(){
        return model('admin/Admin')->is_login();
    }
}